import * as types from './mutation-types'
import $http from '@/api'
export const addToCart = ({ commit, state }, data) => {
  // 添加产品id到购物车
  commit(types.ADD_TO_CART, data)
}

export const decreaseCart = ({ commit }, data) => {
  // 添加产品id到购物车
  commit(types.DECREASE_CART, data)
}

export const getFree = ({ commit }) => {
  $http.getFree()
  .then(res => {
    if (res.code === 0) {
      commit(types.GET_FREE, res.data)
    }
  })
}

export const hideCartList = ({ commit }) => {
  commit(types.HIDE_CART_LIST)
}
